package com.gulimall.product.web;

import com.gulimall.product.service.SkuInfoService;
import com.gulimall.product.vo.SkuItemVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @author kkk
 * @date 2022/7/29
 */
@Controller
public class ItemController {
    @Autowired
    private SkuInfoService skuInfoService;

    /**
     * 展现当前sku的详情
     */
    @GetMapping("/{skuId}.html")
    public String skuItem(@PathVariable Long skuId, Model model) {
        SkuItemVO skuItem = skuInfoService.getSkuItemInfo(skuId);

        model.addAttribute("skuItem", skuItem);
        return "item";
    }
}
